package cn.gz.demo.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import cn.gz.demo.R;

/**
 * Created by Liuyz on 2017/12/4.
 */
public class RollRecylerViewListAdapter extends RecyclerView.Adapter<RollRecylerViewListAdapter.MyViewHolder> {
    private Activity context;
    private List<String> list;

    public RollRecylerViewListAdapter(Activity activity, List<String> response) {
        this.context = activity;
        this.list = response;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.house_search_list_item, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        String bean = list.get(position % list.size());
        holder.item_title.setText(bean + "");
    }

    @Override
    public int getItemCount() {
        return Integer.MAX_VALUE;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        private RelativeLayout item_layout;
        private TextView item_title;

        public MyViewHolder(View view) {
            super(view);
            item_layout = (RelativeLayout) view.findViewById(R.id.house_search_list_item_layout);
            item_title = (TextView) view.findViewById(R.id.house_search_list_item_title);
        }
    }
}
